<?php
/**
 * Created by PhpStorm.
 * User: ly
 * Date: 2017\12\11 0011
 * Time: 19:09
 */
use yii\widgets\LinkPager;
?>
<form class="" id="projectListForm">
						<div class="perfect-logo">
							<img src="/image/officeHall/uploadAssetPackage/wsxx.png" class="pull-left">
							<span class="pull-left">项目清单</span>
						</div>

						<div class="table-responsive pull-left" style="margin-bottom: 20px;">
							<table class="table" id="projectlist">
								<thead>
                                    <tr>
                                        <th class="text-center" width="45">序号</th>
                                        <th class="text-left">借款人名称</th>
                                        <th class="text-left">本金</th>
                                        <th class="text-left">利息</th>
                                        <th class="text-left">本息合计</th>
                                        <th class="text-center">诉讼状态</th>
                                        <th class="text-left">保证人/抵押人</th>
                                        <th class="text-left">担保方式</th>
                                    </tr>
								</thead>
								<tbody>
									<?PHP
                                        $i=(Yii::$app->request->get('page',1)-1)*10+1;
                                        $delbut='';//删除按钮的list
                                       // var_dump($data['projectlist']);
                                        foreach($data['projectlist'] as $val){
                                            switch ($val['is_suit'])
                                            {
                                                case 2:
                                                    $foneS='';
                                                    $zeroS='';
                                                    $oneS='';
                                                    $twoS='selected = "selected"';
                                                    break;
                                                case 1:
                                                    $foneS='';
                                                    $zeroS='';
                                                    $oneS='selected = "selected"';
                                                    $twoS='';
                                                    break;
                                                case 0:
                                                    $foneS='';
                                                    $zeroS='selected = "selected"';
                                                    $oneS='';
                                                    $twoS='';
                                                    break;
                                                default:
                                                    $foneS='selected = "selected"';
                                                    $zeroS='';
                                                    $oneS='';
                                                    $twoS='';
                                            }
                                            $is_suit='<select name="is_suit'.$val['id'].'">
                                                      <option value="-1" '.$foneS.'>无</option>
                                                      <option value="0" '.$zeroS.'>未诉</option>
                                                      <option value="1" '.$oneS.'>已诉</option>
                                                      <option value="2" '.$twoS.'>部分诉讼</option>
                                                    </select>';
                                            echo '<tr class="text-left" id="projectTr'.$val['id'].'">
                                                        <td class="text-center">'.$i.'</td>
                                                        <td><input type="text" name="borrower'.$val['id'].'" value="'.$val['borrower'].'"></td>
                                                        <td><input type="text" name="principal'.$val['id'].'" value="'.Yii::$app->formatter->asDecimal($val['principal']).'"></td>
                                                        <td><input type="text" name="interest'.$val['id'].'" value="'.Yii::$app->formatter->asDecimal($val['interest']).'"></td>
                                                        <td><input type="text" name="benxi'.$val['id'].'" value="'.Yii::$app->formatter->asDecimal($val['principal']+$val['interest']).'"></td>
                                                        <td>'.$is_suit.'</td>
                                                        <td><input type="text" name="guarantor'.$val['id'].'" value="'.$val['guarantor'].'"></td>
                                                        <td><input type="text" name="warranty'.$val['id'].'" value="'.$val['warranty'].'"></td>
                                                    </tr>';
                                            //<td><input type="text" name="is_suit'.$val['id'].'" value="'.$val['is_suit'].'"></td>
                                            $delbut.='<li projectid="'.$val['id'].'" ></li>';
                                            $i++;
                                        }
                                    ?>

</tbody>
</table>
</div>
<!-- 增删按钮 -->
<ul class="table-addpop pull-left" id="delproject">
    <?php echo $delbut; ?>
</ul>
<!-- 表格结束 -->
<!-- 分页 -->
<?PHP
echo LinkPager::widget([
    'pagination' => $pages,
    'firstPageLabel' => '首页',
    'lastPageLabel' => '尾页',
    'nextPageLabel' => '下一页',
    'prevPageLabel' => '上一页'
]);
?>
    <!-- 结束按钮 -->
<div class=" btns">
    <button type="button" class="maintenance-btn-sav btn btn-primary btns-primary-save pull-right btns-primary projectList-btn"  id="projectSubmit">提交</button>
    <button type="button" class="maintenance-btn-del btn btn-default btns-primary-del pull-right btns-primary projectList-btn" onclick="window.history.back();">上一步</button>
</div>
</form>
<script type="text/javascript">
    $(".pagination a").click(function (e) {
        e.preventDefault();
        var url=$(this).attr('href');
        $.get(url,function(msg){
            //alert(msg);
            $('.projectList').html(msg);
        })

    });
</script>